/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/6/23
 * Time: 22:41
 */

#include "UiMouse.h"
UIMouse * UIMouse::AddUIMouseChild(Object * _parent, const std::string & _file_path1, const std::string & _file_path2, float _scale, Anchor _anchor)
{
    auto ui_mouse = new UIMouse();
    ui_mouse->Init();
    ui_mouse->sprite1_ = Sprite::AddSpriteChild(ui_mouse, _file_path1, _scale, _anchor);
    ui_mouse->sprite2_ = Sprite::AddSpriteChild(ui_mouse, _file_path2, _scale, _anchor);
    if(nullptr != _parent)
        _parent->AddChild(ui_mouse);
    return ui_mouse;
}

void UIMouse::Update(float _dt)
{
    timer_ += _dt;
    if(timer_ < 0.3f) {
        sprite1_->SetActive(true);
        sprite2_->SetActive(false);
    }
    else if(timer_ < 0.6f) {
        sprite1_->SetActive(false);
        sprite2_->SetActive(true);
    }
    else {
        timer_ = 0;
    }
    SetRenderPosition(game_.MousePosition());
}